package android.gpsmessenger;

import android.os.Bundle;
import android.app.ListFragment;

import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;

import android.widget.Toast;

public class ProfileFragment extends ListFragment
{
	private boolean saveData = true;
	
	public void onCreate (Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);
	}
		
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
	{
		inflater.inflate(R.menu.fragment_ok_cancel_menu, menu);
	}
	
	public void onResume() 
	{
		super.onResume();
		saveData = true;
	}

	public void onPause() 
	{
	    super.onPause();
	}	
		
	@Override
	public void onActivityCreated(Bundle savedInstanceState) 
	{
		super.onActivityCreated(savedInstanceState);
    }
	
	public boolean onOptionsItemSelected (MenuItem item) 
	{
		switch (item.getItemId()) 
		{
		 	case R.id.menu_ok:
		 		if(validated()) 
		 		{
		 			saveData = true;
		 			getActivity().finish();
		 		} 
		 		else 
		 		{
		 			WarningDialog.showDialog(getActivity());
		 			//Toast.makeText(getActivity(), 
		 			//"You have missing or incorrect values in some form fieds!", Toast.LENGTH_SHORT).show();
		 		}
		 		break;
		 	case R.id.menu_cancel:
		 		saveData = false;
		 		getActivity().finish();
		 		break;
		 }
		return true;
	}	
	
	protected boolean validated() 
	{
		return true;
	}			

}
